package com.example.demo;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import java.net.URI;

@Configuration
public class RestTemplateConfig {
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

        String uriTemplate = "https://example.com/hotels/{hotel}";
        URI uri = UriComponentsBuilder.fromUriString(uriTemplate).build(42);

        RequestEntity<Void> requestEntity = (RequestEntity<Void>) RequestEntity.get(uri)
                .header("MyRequestHeader", "MyValue")
                .build();

        RestTemplate template = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
        ResponseEntity<String> response = template.exchange(requestEntity, String.class);

        String responseHeader = response.getHeaders().getFirst("MyResponseHeader");
        String body = response.getBody();
}
